﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PreeRegisterModel;
using System.Data;
using PreeRegisterDAL;
using DrSoftsFrame;

namespace PreeRegisterBLL
{
    public class DeptGetBLL
    {
        /// <summary>
        /// 科室获取
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static DeptGetResponseBodyModel DeptGet(DeptGet deptget)
        {
            try
            {

                //获取科室信息
                DeptGetResponseBodyModel deptGetResponseBodyModel = GetDept(deptget);

                return deptGetResponseBodyModel;
            }
            catch (Exception err)
            {
                throw;
            }
        }

        /// <summary>
        /// 获取科室
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private static DeptGetResponseBodyModel GetDept(DeptGet deptget)
        {
            try
            {
                //查询科室表
                DeptGetResponseBodyModel deptGetResponseBodyModel = new PreeRegisterModel.DeptGetResponseBodyModel();

                int iPreeDay = WorkGetDAL.GetPreeDay(Common.ToInt(deptget.preetype));

                DataSet ds = DeptGetDAL.GetDeptInfo(iPreeDay);

                //获取科室更新情况
                List<DeptGetModel> DeptGetModel_list = new List<DeptGetModel>();

                foreach (DataRow drDept in ds.Tables["DictDept"].Rows)
                {
                    DeptGetModel deptGetModel = new DeptGetModel();

                    deptGetModel.id = drDept["No_Dept"].ToString();
                    deptGetModel.name = drDept["DeptName"].ToString();

                    DeptGetModel_list.Add(deptGetModel);
                }

                deptGetResponseBodyModel.depts = DeptGetModel_list;

                //返回
                return deptGetResponseBodyModel;
            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
